$(document).ready(function(){
	
	//$("#LEFT-PART").mCustomScrollbar();
	
	(function($){
		$(window).load(function(){
			$("#photo_list").mCustomScrollbar({

			});
		});
	})(jQuery);
	
	function onWindowResize() {
		//TODO review this!
		h = $(window).height() - $("#main_menu").height() - 60;
		$("#photo_list").height(h);
		$("#CONTENT-PART").height($(window).height() - 20);
		calculateImageSize("#ajax-img");
	}
	
	onWindowResize();
	$(window).resize(function(){
		onWindowResize();
	});
	
	function calculateImageSize(imageObject) {
		var container_height = $("#CONTENT-PART").height();
		var container_width = $("#CONTENT-PART").width() / 1.5;
		
		//getting image size
		var img_height = 1200;
		var img_width = 900;
//		var img_height = $(imageObject).height();
//		var img_width = $(imageObject).width();
		
		
		var range_height = img_height / container_height;
		var range_width = img_width / container_width;
		if (range_height > 1 || range_width > 1) {
			if (range_width > range_height) {
				$(imageObject).width(img_width / range_width);
				$(imageObject).height(img_height / range_width);
			} else {
				$(imageObject).width(img_width / range_height);
				$(imageObject).height(img_height / range_height);
				
			}
		}
	}
	
	$("a.thumb_link").click(function(e){
		e.preventDefault();
		var href = $(this).attr("href");
		$("#ajax-img").attr("src" , href);
		calculateImageSize($("#ajax-img"));
		
	});
	
	$dragger_container=$("#dragger_container");
	$dragger=$("#dragger");
	
});